$(function() {

	$('#currentDay').html(year + "年" + month + "月" + date + "日");

	navList = $("ul li");
	navList.each(function() {
		try {
			sonElement = $(this).html();
			if (sonElement.indexOf(nav) != -1) {
				$(this).addClass("active");
			}

		} catch (e) {

		}

	});

	$('ul.dropdown-menu [data-toggle=dropdown]').on('click', function(event) {
		event.preventDefault();
		event.stopPropagation();
		$('ul.dropdown-menu [data-toggle=dropdown]').parent().removeClass('open');
		$(this).parent().addClass('open');
		var menu = $(this).parent().find("ul");
		var menupos = menu.offset();
		if ((menupos.left + menu.width()) + 30 > $(window).width()) {
			var newpos = -menu.width();
		} else {
			var newpos = $(this).parent().width();
		}
		menu.css({
			left : newpos
		});

	});

});
